package com.zzb.auth.controller;

import com.zzb.ucenter.model.dto.XcUserExt;
import com.zzb.ucenter.service.impl.WxAuthServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author zzb
 * @Date 2024/6/28 20:37
 * @Version 1.0
 * @description
 */
@Slf4j
@Controller
public class WxLoginController {
    @Autowired
    private WxAuthServiceImpl wxAuthService;

    @RequestMapping("/wxLogin")
    public String wxLogin(String code, String state) {
        XcUserExt xcUserExt = wxAuthService.wxAuth(code);
        if (xcUserExt == null) {
            return "redirect:http://www.51xuecheng.cn/error.html";
        }
        String username = xcUserExt.getUsername();
        return "redirect:http://www.51xuecheng.cn/sign.html?username=" + username + "&authType=wx";
    }

}
